import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangshuai
 * @version V1.0
 * @Project Java2_26
 * @Package PACKAGE_NAME
 * @Description:
 * @Date 2025/5/19 16:43
 */

public class Demo6 {

    public static void main(String[] args) {
        //规定上限,上限不能确定
        List<? extends Animal> extendList = new ArrayList<>();
        /*extendList.add(new Animal()); //无法添加
        extendList.add(new Dog());*/   //无法添加
        extendList.add(null);
        System.out.println(extendList);


        //规定下限 ？可以是当前类及其子类
        List<? super Animal> superList = new ArrayList<>();
        superList.add(new Animal());
        superList.add(new Dog());
        System.out.println(superList);




    }
}
class Animal extends Demo3{
    @Override
    public String toString() {
        return "Animal{}";
    }
}
class Dog extends Animal{
    @Override
    public String toString() {
        return "Dog{}";
    }
}
class Cat extends Animal{}